<template>
  <div class="app-container">
    <router-view v-if="$route.params.waveformId" />
    <div v-else class="card-container">
      <el-card>
        <div slot="header" class="clearfix">
          <span>波形示教</span>
        </div>
        <div class="content">
          <!-- 提示信息 -->
          <p class="device-prompt">尚未选择设备，即将为您跳转至设备画像，请您进行设备选择</p>

          <!-- 按钮区域 -->
          <div class="button-group">
            <el-button @click="goBack">取消</el-button>
            <el-button type="primary" @click="goToDeviceProfile">确定</el-button>
          </div>
        </div>
      </el-card>
    </div>
  </div>
</template>


<script>
import { listDevice } from '@/api/gelly/device'
import axios from 'axios'
export default {
  name: "WaveformIndex",
  beforeRouteEnter(to, from, next) {
    next(vm => {
      if (from.name === 'Index' || from.name === 'RealManage') {
        // 1. 取消所有未完成的 axios 请求（如果有）
        const source = axios.CancelToken.source();
        source.cancel("离开 Index 页面，取消所有请求");

        // 2. 强制刷新当前页面
        window.location.reload();
      }
    });
  },
  data() {
    return {
      deviceList: [],

    }
  },
  created() {

  },
  methods: {
    // 移除了 handleDeviceChange 和 getDeviceList
    goBack() {
      this.$router.go(-1);
    },
    goToDeviceProfile() {
      this.$router.push('/gelly/device');
    }
  }
}
</script>

<style lang="scss" scoped>
.card-container {
  background-color: #f5f7fa;
  padding: 20px;
}

.content {
  padding: 20px;
  text-align: center;
  background: linear-gradient(to right, #ffffff, #fcfdff);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.device-prompt {
  font-size: 20px;
  font-weight: bold;
  color: #333333;
  margin-bottom: 20px;
}

.button-group {
  margin-top: 20px;

  .el-button {
    margin: 0 10px;
    border-radius: 4px;
    padding: 10px 20px;
  }
}
</style>

